"use strict";
(() => {
  var __defProp = Object.defineProperty;
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  var __decorateClass = (decorators, target, key, kind) => {
    var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
    for (var i = decorators.length - 1, decorator; i >= 0; i--)
      if (decorator = decorators[i])
        result = (kind ? decorator(target, key, result) : decorator(result)) || result;
    if (kind && result)
      __defProp(target, key, result);
    return result;
  };

  // src/TagetMove/TargetMove2D.ts
  var TargetMove2D = class {
    constructor(role) {
      this.role = role;
      this._forwardlenth = new Laya.Vector2();
    }
    onBegin() {
    }
    onUpdate() {
      this.role.x += this._forwardlenth.x;
      this.role.y += this._forwardlenth.y;
    }
    onMove(curDis, curAngle, offsetAngle = 0) {
      this.role.rotation = curAngle + 90 + offsetAngle;
      this._forwardlenth.x = Math.cos(curAngle * Math.PI / 180) * curDis;
      this._forwardlenth.y = Math.sin(curAngle * Math.PI / 180) * curDis;
    }
    onEnd() {
      this._forwardlenth.setValue(0, 0);
    }
  };

  // src/TagetMove/TargetMove3D.ts
  var TargetMove3D = class {
    constructor(role) {
      this.role = role;
      this._forwardlenth = new Laya.Vector3();
    }
    onBegin() {
    }
    onUpdate() {
      var curpos = this.role.transform.position;
      curpos.vadd(this._forwardlenth, curpos);
      this.role.transform.position = curpos;
    }
    onMove(curDis, curAngle, offsetAngle) {
      let delatx = Math.cos(curAngle * Math.PI / 180);
      let delaty = Math.sin(curAngle * Math.PI / 180);
      let angle = Math.atan2(delatx, delaty) * 180 / Math.PI - 180;
      this.role.transform.localRotationEulerY = angle + offsetAngle;
      var forward = new Laya.Vector3();
      this.role.transform.getForward(forward);
      Laya.Vector3.normalize(forward, forward);
      Laya.Vector3.scale(forward, curDis, this._forwardlenth);
    }
    onEnd() {
      this._forwardlenth.setValue(0, 0, 0);
    }
  };

  // src/TagetMove/TargetMovePhysic2D.ts
  var TargetMovePhysic2D = class {
    constructor(role) {
      this.role = role;
      this._forwardlenth = new Laya.Vector2();
    }
    onBegin() {
    }
    onUpdate() {
      let rigBody = this.role.getComponent(Laya.RigidBody);
      rigBody && rigBody.setVelocity({ x: this._forwardlenth.x, y: this._forwardlenth.y });
    }
    onMove(curDis, curAngle, offsetAngle) {
      this.role.rotation = curAngle + 90 + offsetAngle;
      this._forwardlenth.x = Math.cos(curAngle * Math.PI / 180) * curDis;
      this._forwardlenth.y = Math.sin(curAngle * Math.PI / 180) * curDis;
    }
    onEnd() {
      this._forwardlenth.setValue(0, 0);
      let rigBody = this.role.getComponent(Laya.RigidBody);
      rigBody && rigBody.setVelocity({ x: 0, y: 0 });
    }
  };

  // src/TagetMove/TargetMovePhysic3D.ts
  var TargetMovePhysic3D = class {
    constructor(role) {
      this.role = role;
      this._forwardlenth = new Laya.Vector3();
    }
    onBegin() {
    }
    onUpdate() {
      let rigBody = this.role.getComponent(Laya.Rigidbody3D);
      if (rigBody) {
        rigBody.linearVelocity = this._forwardlenth;
      }
    }
    onMove(curDis, curAngle, offsetAngle) {
      let delatx = Math.cos(curAngle * Math.PI / 180);
      let delaty = Math.sin(curAngle * Math.PI / 180);
      let angle = Math.atan2(delatx, delaty) * 180 / Math.PI - 180;
      var forward = new Laya.Vector3();
      this.role.transform.getForward(forward);
      Laya.Vector3.normalize(forward, forward);
      Laya.Vector3.scale(forward, curDis, this._forwardlenth);
      let rigBody = this.role.getComponent(Laya.Rigidbody3D);
      let qua = new Laya.Quaternion();
      let rad = (angle + offsetAngle) / 180 * Math.PI;
      qua.rotateY(rad, qua);
      rigBody.orientation = qua;
    }
    onEnd() {
      this._forwardlenth.setValue(0, 0, 0);
      let rigBody = this.role.getComponent(Laya.Rigidbody3D);
      rigBody && (rigBody.linearVelocity = Laya.Vector3.ZERO);
    }
  };

  // src/TagetMove/TargetMove.ts
  var { property, classInfo, regClass } = Laya;
  var TargetMove = class extends Laya.Component {
    constructor() {
      super(...arguments);
      this.maxSpeed = 100;
      /**
       * 当前移动速度
       */
      this.curSpeed = 0;
      /**
       * 当前移动角度
       */
      this.curAngle = 0;
      /**
       * 当前移动弧度
       */
      this.curRadian = 0;
      //偏移角度：针对当摄像机影响物体的旋转时
      this.offsetAngle = 0;
    }
    onStart() {
      this.setMoveLogic(this.is2D, this.isPhysic);
    }
    setMoveLogic(is2D, isPhysic) {
      if (is2D) {
        if (isPhysic) {
          this._moveLogic = new TargetMovePhysic2D(this.owner);
        } else {
          this._moveLogic = new TargetMove2D(this.owner);
        }
      } else {
        if (isPhysic) {
          this._moveLogic = new TargetMovePhysic3D(this.owner);
        } else {
          this._moveLogic = new TargetMove3D(this.owner);
        }
      }
    }
    onUpdate() {
      if (this.isMoving) {
        this._moveLogic.onUpdate && this._moveLogic.onUpdate();
      }
    }
    onBegin() {
      this._moveLogic && this._moveLogic.onBegin();
    }
    onMove(curDis, curAngle) {
      this.isMoving = true;
      this.curSpeed = curDis * this.maxSpeed * Laya.timer.delta / 1e3;
      this.curAngle = curAngle;
      this.curRadian = curAngle * Math.PI / 180;
      this._moveLogic && this._moveLogic.onMove(this.curSpeed, this.curAngle, this.offsetAngle);
    }
    onEnd() {
      this.curSpeed = 0;
      this.isMoving = false;
      this._moveLogic && this._moveLogic.onEnd();
    }
  };
  __decorateClass([
    property({ type: Boolean, tips: "\u662F\u5426\u662F2D\u7269\u4F53" })
  ], TargetMove.prototype, "is2D", 2);
  __decorateClass([
    property({ type: Boolean, tips: "\u662F\u5426\u4F7F\u7528\u7269\u7406\u79FB\u52A8" })
  ], TargetMove.prototype, "isPhysic", 2);
  __decorateClass([
    property({ type: Number, tips: "\u6700\u5927\u79FB\u52A8\u901F\u5EA6" })
  ], TargetMove.prototype, "maxSpeed", 2);
  TargetMove = __decorateClass([
    regClass("WAs2H1fkSKeHqH_oNGogoQ"),
    classInfo({
      menu: "TargetControl",
      caption: "TargetMove"
    })
  ], TargetMove);

  // src/CameraFollow/CameraFollow2D.ts
  var CameraFollow2D = class {
    //#endregion
    initCamera(data) {
      this._targetMove = data.target;
      this._mapArea = data.mapArea;
      this._touchArea = data.touchArea;
      this._target = this._targetMove.owner;
      if (this._mapArea) {
        this.updateDragRect();
        if (this._touchArea) {
          this._touchArea.on(Laya.Event.MOUSE_DOWN, this, this.beginDragRect);
          this._touchArea.on(Laya.Event.MOUSE_UP, this, this.endDragRect);
          this._touchArea.on(Laya.Event.MOUSE_OUT, this, this.endDragRect);
        }
      }
    }
    //#region 摄像机拖动逻辑
    beginDragRect() {
      this._mapArea.startDrag(this._dragRect);
    }
    updateDragRect() {
      let hwidth = Laya.stage.displayWidth;
      let hheight = Laya.stage.displayHeight;
      let minX = Math.min(hwidth - this._mapArea.displayWidth, this._mapArea.displayWidth - hwidth);
      let maxX = Math.max(hwidth - this._mapArea.displayWidth, this._mapArea.displayWidth - hwidth);
      let minY = Math.min(hheight - this._mapArea.displayHeight, this._mapArea.displayHeight - hheight);
      let maxY = Math.max(hheight - this._mapArea.displayHeight, this._mapArea.displayHeight - hheight);
      this._dragRect = new Laya.Rectangle(minX, minY, maxX, maxY);
    }
    endDragRect() {
      this._mapArea.stopDrag();
    }
    //#endregion
    onLateUpdate() {
      if (this._target) {
        this.sysPosition();
      }
    }
    //同步位置
    sysPosition() {
      if (this._targetMove.isMoving) {
        let dx = Math.cos(this._targetMove.curRadian) * this._targetMove.curSpeed;
        let dy = Math.sin(this._targetMove.curRadian) * this._targetMove.curSpeed;
        if (dx < 0 && this._mapArea.x < 0 || dx > 0 && this._mapArea.x > Laya.stage.displayWidth - this._mapArea.displayWidth) {
          this._mapArea.x -= dx;
        }
        if (dy < 0 && this._mapArea.y < 0 || dy > 0 && this._mapArea.y > Laya.stage.displayHeight - this._mapArea.displayHeight) {
          this._mapArea.y -= dy;
        }
      }
    }
    onDisable() {
      if (this._touchArea) {
        this._touchArea.off(Laya.Event.MOUSE_DOWN, this, this.beginDragRect);
        this._touchArea.off(Laya.Event.MOUSE_UP, this, this.endDragRect);
        this._touchArea.off(Laya.Event.MOUSE_OUT, this, this.endDragRect);
      }
      this._target = null;
    }
  };

  // src/CameraFollow/CameraFollowFix.ts
  var CameraFollowFix = class {
    constructor() {
      this._dragOffset = new Laya.Vector3();
      this._controlEnable = true;
      //是否操作相机
      this._touchid = -1;
      this._dragSpeed = 1e-3;
      //相机位置
      this._upVector = new Laya.Vector3(0, 1, 0);
      this._positionSpeed = 0.01;
    }
    //位置跟随速度
    //#endregion
    initCamera(data) {
      this._camera = data.camera;
      this._target = data.target.owner;
      this._touchArea = data.touchArea;
      this._offsetPos = data.posOffset || new Laya.Vector3();
      this._cameraTargetPos = new Laya.Vector3();
      this._cameraOffsetPos = new Laya.Vector3();
      if (this._touchArea) {
        this._controlEnable = true;
        this._touchArea.on(Laya.Event.MOUSE_DOWN, this, this.mouseDown);
      } else {
        this._controlEnable = false;
      }
      if (this._target) {
        this._cameraTarget = new Laya.Sprite3D("cameraParent");
        this._camera.parent.addChild(this._cameraTarget);
        this._target.transform.position.cloneTo(this._cameraTargetPos);
        this._cameraTarget.transform.position = this._cameraTargetPos.clone();
        this._cameraTarget.addChild(this._camera);
        this._camera.transform.localPosition = this._offsetPos;
        this._camera.transform.lookAt(this._target.transform.position, this._upVector, false);
      }
    }
    onLateUpdate() {
      if (this._target && this._target.transform && this._cameraTarget) {
        this.sysPosition();
      }
    }
    //#region 鼠标控制逻辑
    mouseDown(e) {
      if (!this._controlEnable)
        return;
      if (this._touchid != -1)
        return;
      Laya.stage.on(Laya.Event.BLUR, this, this.mouseUp);
      Laya.stage.on(Laya.Event.MOUSE_MOVE, this, this.mouseMove);
      Laya.stage.on(Laya.Event.MOUSE_UP, this, this.mouseUp);
      Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.mouseUp);
      this._touchid = e.touchId;
      this._lastMouseX = Laya.stage.mouseX;
      this._lastMouseY = Laya.stage.mouseY;
      this._isMouseDown = true;
    }
    mouseMove(e) {
      if (!this._controlEnable)
        return;
      if (e.touchId == this._touchid) {
        var elapsedTime = Laya.timer.delta;
        if (!isNaN(this._lastMouseX) && !isNaN(this._lastMouseY) && this._isMouseDown) {
          var offsetX = Laya.stage.mouseX - this._lastMouseX;
          var offsetY = Laya.stage.mouseY - this._lastMouseY;
          this._dragOffset.x += offsetX * this._dragSpeed * elapsedTime;
          this._dragOffset.z += offsetY * this._dragSpeed * elapsedTime;
          this._lastMouseX = Laya.stage.mouseX;
          this._lastMouseY = Laya.stage.mouseY;
        }
      }
    }
    mouseUp(e) {
      if (e.touchId != this._touchid)
        return;
      Laya.stage.off(Laya.Event.BLUR, this, this.mouseUp);
      Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.mouseMove);
      Laya.stage.off(Laya.Event.MOUSE_UP, this, this.mouseUp);
      Laya.stage.off(Laya.Event.MOUSE_OUT, this, this.mouseUp);
      this._isMouseDown = false;
      this._touchid = -1;
    }
    //#endregion
    //同步位置
    sysPosition() {
      Laya.Vector3.lerp(this._cameraTargetPos, this._target.transform.position, this._positionSpeed, this._cameraTargetPos);
      this._cameraTarget.transform.position = this._cameraTargetPos.clone();
      if (this._controlEnable) {
        Laya.Vector3.add(this._dragOffset, this._offsetPos, this._cameraOffsetPos);
        this._camera.transform.localPosition = this._cameraOffsetPos.clone();
      } else {
        this._camera.transform.lookAt(this._cameraTargetPos, this._upVector, false);
      }
    }
    onDisable() {
      if (this._touchArea) {
        this._touchArea.off(Laya.Event.MOUSE_DOWN, this, this.mouseDown);
      }
      Laya.stage.offAllCaller(this);
      this._target = null;
      this._camera = null;
      this._touchid = -1;
    }
  };

  // src/CameraFollow/CameraFollowFree.ts
  var CameraFollowFree = class {
    constructor() {
      this._upangle = 0;
      this._downangle = 0;
      this._rotationEuler = new Laya.Vector3();
      this._controlEnable = true;
      //是否操作相机
      this._touchid = -1;
      //相机父节点旋转
      this._upVector = new Laya.Vector3(0, 1, 0);
      this._positionSpeed = 1;
      //位置跟随速度
      this._rotaionSpeed = 0.01;
      //旋转跟随速度
      this._lastRotationY = 0;
    }
    //#endregion
    initCamera(data) {
      this._camera = data.camera;
      this._target = data.target.owner;
      this._touchArea = data.touchArea;
      this._offsetPos = data.posOffset || new Laya.Vector3();
      this._upangle = data.upAngle || 0;
      this._downangle = data.downangle || 0;
      this._cameraTargetPos = new Laya.Vector3();
      this._cameraTargetRot = new Laya.Vector3();
      if (this._touchArea) {
        this._controlEnable = true;
        this._touchArea.on(Laya.Event.MOUSE_DOWN, this, this.mouseDown);
      } else {
        this._controlEnable = false;
      }
      if (this._target) {
        this._cameraTarget = new Laya.Sprite3D("cameraParent");
        this._camera.parent.addChild(this._cameraTarget);
        this._target.transform.position.cloneTo(this._cameraTargetPos);
        this._cameraTarget.transform.position = this._cameraTargetPos.clone();
        this._cameraTarget.addChild(this._camera);
        this._camera.transform.localPosition = this._offsetPos;
        this._camera.transform.lookAt(this._target.transform.position, this._upVector, false);
        this._cameraTarget.transform.localRotationEuler.cloneTo(this._cameraTargetRot);
      }
    }
    onLateUpdate() {
      if (this._target && this._target.transform && this._cameraTarget) {
        this.sysPosition();
      }
    }
    //#region 鼠标控制逻辑
    mouseDown(e) {
      if (!this._controlEnable)
        return;
      if (this._touchid != -1)
        return;
      Laya.stage.on(Laya.Event.BLUR, this, this.mouseUp);
      Laya.stage.on(Laya.Event.MOUSE_MOVE, this, this.mouseMove);
      Laya.stage.on(Laya.Event.MOUSE_UP, this, this.mouseUp);
      Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.mouseUp);
      this._touchid = e.touchId;
      this._rotationEuler.setValue(this._cameraTarget.transform.localRotationEulerX, this._cameraTarget.transform.localRotationEulerY, this._cameraTarget.transform.localRotationEulerZ);
      this._lastMouseX = Laya.stage.mouseX;
      this._lastMouseY = Laya.stage.mouseY;
      this._isMouseDown = true;
    }
    mouseMove(e) {
      if (!this._controlEnable)
        return;
      if (e.touchId == this._touchid) {
        var elapsedTime = Laya.timer.delta;
        if (!isNaN(this._lastMouseX) && !isNaN(this._lastMouseY) && this._isMouseDown) {
          var offsetX = Laya.stage.mouseY - this._lastMouseY;
          var offsetY = Laya.stage.mouseX - this._lastMouseX;
          this._rotationEuler.x -= offsetX * this._rotaionSpeed * elapsedTime;
          this._rotationEuler.y -= offsetY * this._rotaionSpeed * elapsedTime;
          if (Math.abs(this._rotationEuler.y - this._lastRotationY) > 1) {
            this._lastRotationY = this._rotationEuler.y;
          }
          this.sysRotation();
          this._lastMouseX = Laya.stage.mouseX;
          this._lastMouseY = Laya.stage.mouseY;
        }
      }
    }
    mouseUp(e) {
      if (e.touchId != this._touchid)
        return;
      Laya.stage.off(Laya.Event.BLUR, this, this.mouseUp);
      Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.mouseMove);
      Laya.stage.off(Laya.Event.MOUSE_UP, this, this.mouseUp);
      Laya.stage.off(Laya.Event.MOUSE_OUT, this, this.mouseUp);
      this._isMouseDown = false;
      this._touchid = -1;
    }
    //#endregion
    //同步旋转
    sysRotation() {
      if (this._upangle) {
        if (this._rotationEuler.x < -this._upangle)
          this._rotationEuler.x = -this._upangle;
      }
      if (this._downangle) {
        if (this._rotationEuler.x > this._downangle)
          this._rotationEuler.x = this._downangle;
      }
      this._cameraTarget.transform.localRotationEuler = this._rotationEuler;
      let targetMove = this._target.getComponent(TargetMove);
      targetMove.offsetAngle = this._rotationEuler.y;
    }
    //同步位置
    sysPosition() {
      Laya.Vector3.lerp(this._cameraTargetPos, this._target.transform.position, this._positionSpeed, this._cameraTargetPos);
      this._cameraTarget.transform.position = this._cameraTargetPos.clone();
      if (this._controlEnable) {
      } else {
        this._camera.transform.lookAt(this._cameraTargetPos, this._upVector, false);
      }
    }
    onDisable() {
      if (this._touchArea) {
        this._touchArea.off(Laya.Event.MOUSE_DOWN, this, this.mouseDown);
      }
      Laya.stage.offAllCaller(this);
      this._target = null;
      this._camera = null;
      this._touchid = -1;
    }
  };

  // src/CameraFollow/CameraFollowTail.ts
  var CameraFollowTail = class {
    constructor() {
      //相机父节点旋转
      this._upVector = new Laya.Vector3(0, 1, 0);
      this._positionSpeed = 0.01;
      //位置跟随速度
      this._rotationSpeed = 1;
    }
    //位置跟随速度
    //#endregion
    initCamera(data) {
      this._camera = data.camera;
      this._target = data.target.owner;
      this._offsetPos = data.posOffset || new Laya.Vector3();
      this._cameraTargetPos = new Laya.Vector3();
      this._cameraTargetRot = new Laya.Vector3();
      if (this._target) {
        this._cameraTarget = new Laya.Sprite3D("cameraParent");
        this._camera.parent.addChild(this._cameraTarget);
        this._target.transform.position.cloneTo(this._cameraTargetPos);
        this._cameraTarget.transform.position = this._cameraTargetPos.clone();
        this._cameraTarget.addChild(this._camera);
        this._camera.transform.localPosition = this._offsetPos;
        this._camera.transform.lookAt(this._cameraTargetPos, this._upVector, false);
        this._cameraTarget.transform.localRotationEuler.cloneTo(this._cameraTargetRot);
      }
    }
    onLateUpdate() {
      if (this._target && this._target.transform && this._cameraTarget) {
        this.sysPosition();
        this.sysRotation();
      }
    }
    //同步旋转
    sysRotation() {
      Laya.Vector3.lerp(this._cameraTargetRot, this._target.transform.localRotationEuler, this._rotationSpeed, this._cameraTargetRot);
      this._cameraTarget.transform.localRotationEuler = this._cameraTargetRot.clone();
    }
    //同步位置
    sysPosition() {
      Laya.Vector3.lerp(this._cameraTargetPos, this._target.transform.position, this._positionSpeed, this._cameraTargetPos);
      this._cameraTarget.transform.position = this._cameraTargetPos.clone();
      this._camera.transform.lookAt(this._cameraTargetPos, this._upVector, false);
    }
    onDisable() {
      Laya.stage.offAllCaller(this);
      this._target = null;
      this._camera = null;
    }
  };

  // src/CameraFollow/interface/ICameraData.ts
  var CameraType = /* @__PURE__ */ ((CameraType2) => {
    CameraType2["free"] = "free";
    CameraType2["tail"] = "tail";
    CameraType2["fix"] = "fix";
    return CameraType2;
  })(CameraType || {});

  // src/CameraFollow/CameraFollow.ts
  var { property: property2, classInfo: classInfo2, regClass: regClass2 } = Laya;
  var CameraFollow = class extends Laya.Component {
    constructor() {
      super(...arguments);
      this.cameraType = "free" /* free */;
      this.offsetPos = new Laya.Vector3(0, 3, 5);
      this.upAngle = 90;
      this.downangle = 90;
    }
    onAwake() {
      if (this.is2D) {
        this._cameraLogic = new CameraFollow2D();
      } else {
        switch (this.cameraType) {
          case "free" /* free */:
            this._cameraLogic = new CameraFollowFree();
            break;
          case "tail" /* tail */:
            this._cameraLogic = new CameraFollowTail();
            break;
          case "fix" /* fix */:
            this._cameraLogic = new CameraFollowFix();
            break;
          default:
            this._cameraLogic = new CameraFollowFree();
            break;
        }
      }
      this.initCamera();
    }
    onEnable() {
      Laya.stage.on(Laya.Event.MOUSE_WHEEL, this, this.wheelHeadHandler);
    }
    wheelHeadHandler(e) {
      if (this.is2D) {
        let stepPower = 100;
        let maxScale = 5;
        let minScale = 1;
        let scale = parseFloat((e.delta / stepPower + this.mapArea.scaleX).toFixed(2));
        if (scale > maxScale || scale < minScale)
          return;
        let lastWidth = this.mapArea.displayWidth;
        let lastHeight = this.mapArea.displayHeight;
        this.mapArea.scaleX = this.mapArea.scaleY = scale;
        let curWidth = this.mapArea.displayWidth;
        let curHeight = this.mapArea.displayHeight;
        this.mapArea.x += (lastWidth - curWidth) / 2;
        this.mapArea.y += (lastHeight - curHeight) / 2;
      } else {
        let maxDis = 100;
        let minDis = 5;
        let camera = this.owner;
        let offset = camera.transform.localPosition.clone();
        Laya.Vector3.subtract(Laya.Vector3.ZERO, offset, offset);
        Laya.Vector3.normalize(offset, offset);
        Laya.Vector3.scale(offset, e.delta, offset);
        let targetPos = camera.transform.localPosition.clone();
        Laya.Vector3.add(targetPos, offset, targetPos);
        let dis = Laya.Vector3.scalarLength(targetPos);
        if (dis < minDis || dis > maxDis) {
          return;
        }
        camera.transform.localPosition = targetPos;
      }
    }
    initCamera() {
      let cameraData = {
        camera: this.owner,
        target: this.target,
        touchArea: this.touchArea,
        mapArea: this.mapArea,
        posOffset: this.offsetPos,
        upAngle: this.upAngle,
        downangle: this.downangle
      };
      this._cameraLogic.initCamera(cameraData);
    }
    onUpdate() {
      var _a;
      ((_a = this._cameraLogic) == null ? void 0 : _a.onUpdate) && this._cameraLogic.onUpdate();
    }
    onLateUpdate() {
      var _a;
      ((_a = this._cameraLogic) == null ? void 0 : _a.onLateUpdate) && this._cameraLogic.onLateUpdate();
    }
    onDisable() {
      this._cameraLogic && this._cameraLogic.onDisable();
      Laya.stage.off(Laya.Event.MOUSE_WHEEL, this, this.wheelHeadHandler);
    }
  };
  __decorateClass([
    property2({ type: Boolean, tips: "\u662F\u5426\u662F2D\u76EE\u6807" })
  ], CameraFollow.prototype, "is2D", 2);
  __decorateClass([
    property2({ type: Laya.Sprite, tips: "\u63A7\u5236\u8303\u56F4" })
  ], CameraFollow.prototype, "touchArea", 2);
  __decorateClass([
    property2({ type: TargetMove, tips: "\u8DDF\u968F\u76EE\u6807" })
  ], CameraFollow.prototype, "target", 2);
  __decorateClass([
    property2({ type: Laya.Image, hidden: "!data.is2D", tips: "\u5730\u56FE\u8303\u56F4" })
  ], CameraFollow.prototype, "mapArea", 2);
  __decorateClass([
    property2({ type: CameraType, tips: "\u8DDF\u968F\u7C7B\u578B", hidden: "data.is2D", options: { "\u81EA\u7531\u89C6\u89D2": "free" /* free */, "\u8FFD\u5C3E\u89C6\u89D2": "tail" /* tail */, "\u56FA\u5B9A\u89C6\u89D2": "fix" /* fix */ } })
  ], CameraFollow.prototype, "cameraType", 2);
  __decorateClass([
    property2({ type: Laya.Vector3, tips: "\u8DDF\u968F\u4F4D\u7F6E\u504F\u79FB" })
  ], CameraFollow.prototype, "offsetPos", 2);
  __decorateClass([
    property2({ type: Number, hidden: "data.is2D", tips: "\u6700\u5927\u4FEF\u89C6\u89D2" })
  ], CameraFollow.prototype, "upAngle", 2);
  __decorateClass([
    property2({ type: Number, hidden: "data.is2D", tips: "\u6700\u5927\u4EF0\u89C6\u89D2" })
  ], CameraFollow.prototype, "downangle", 2);
  CameraFollow = __decorateClass([
    regClass2("eaN9KDE7TN-4X-2tb2ecTw")
  ], CameraFollow);

  // src/Rocker/data/RockerData.ts
  var RockerType = /* @__PURE__ */ ((RockerType2) => {
    RockerType2["free"] = "free";
    RockerType2["vertical"] = "verticle";
    RockerType2["horizontal"] = "horizontal";
    return RockerType2;
  })(RockerType || {});
  var RockerPos = /* @__PURE__ */ ((RockerPos2) => {
    RockerPos2["fixed"] = "fixed";
    RockerPos2["follow"] = "follow";
    return RockerPos2;
  })(RockerPos || {});
  var RockerShow = /* @__PURE__ */ ((RockerShow2) => {
    RockerShow2["stay"] = "stay";
    RockerShow2["down"] = "down";
    RockerShow2["hide"] = "hide";
    return RockerShow2;
  })(RockerShow || {});

  // src/Rocker/RockerControl.ts
  var { property: property3, regClass: regClass3, classInfo: classInfo3 } = Laya;
  var RockerControl = class extends Laya.Component {
    constructor() {
      super(...arguments);
      this.rockerType = "free" /* free */;
      this.rockerShow = "stay" /* stay */;
      this.rockerPos = "fixed" /* fixed */;
      this.dropdis = 100;
      this.rockerLock = false;
      this.rockerbgRotate = false;
      this.rockerIsDown = false;
      //是否按下
      //#endregion
      //#region 摇杆移动参数
      //上一次位置
      this._prespx = 0;
      this._prespy = 0;
      //按下位置
      this._downspx = 0;
      this._downspy = 0;
      //当前位置
      this._curspx = 0;
      this._curspy = 0;
      this._touchId = -1;
      //#endregion
      this.curAngle = 0;
      this.curDis = 0;
    }
    onAwake() {
      this.rockerBg.visible = this.rockerShow == "stay" /* stay */;
      this.rockerBar.visible = this.rockerShow == "stay" /* stay */;
      this.touchArea.on(Laya.Event.MOUSE_DOWN, this, this.onDown);
    }
    /**
    * 设置摇杆界面
    * @param touch 触屏控制区域
    * @param bg 摇杆背景
    * @param bar 摇杆中心
    */
    setRockerView(touch, bg, bar) {
      this.touchArea = touch;
      this.rockerBg = bg;
      this.rockerBar = bar;
    }
    /**
     * 更新遥感的选中状态
     * @param selected 
     */
    updateSelectState(selected) {
      this.rockerBar.selected = selected;
      this.rockerBg.selected = selected;
    }
    /**鼠标按下 */
    onDown(e) {
      var _a;
      if (this._touchId != -1 || this.rockerLock)
        return;
      e.stopPropagation();
      Laya.stage.on(Laya.Event.BLUR, this, this.onUp);
      Laya.stage.on(Laya.Event.MOUSE_MOVE, this, this.onMove);
      Laya.stage.on(Laya.Event.MOUSE_UP, this, this.onUp);
      Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.onUp);
      this._touchId = e.touchId;
      this.rockerIsDown = true;
      this._prespx = this._downspx = e.stageX;
      this._prespy = this._downspy = e.stageY;
      this.updateSelectState(true);
      if (this.rockerPos == "follow" /* follow */) {
        this.rockerBg.x = this._downspx;
        this.rockerBg.y = this._downspy;
        this._barinitx = this._downspx;
        this._barinity = this._downspy;
      } else {
        this._barinitx = this.rockerBar.x;
        this._barinity = this.rockerBar.y;
      }
      this.rockerBg.visible = this.rockerShow != "hide" /* hide */;
      this.rockerBar.visible = this.rockerShow != "hide" /* hide */;
      ((_a = this.controlTarget) == null ? void 0 : _a.onBegin) && this.controlTarget.onBegin();
    }
    /**鼠标移动 */
    onMove(e) {
      var _a;
      if (this.rockerIsDown && e.touchId == this._touchId) {
        this._curspx = e.stageX;
        this._curspy = e.stageY;
        this.computerRoker();
        this.rockerbgRotate && (this.rockerBg.rotation = this.curAngle);
        ((_a = this.controlTarget) == null ? void 0 : _a.onMove) && this.controlTarget.onMove(this.curDis, this.curAngle);
      }
    }
    /**失去焦点恢复默认状态 */
    onUp() {
      var _a;
      if (!this.rockerBar)
        return;
      this.rockerBg.visible = this.rockerShow == "stay" /* stay */;
      this.rockerBar.visible = this.rockerShow == "stay" /* stay */;
      Laya.stage.off(Laya.Event.BLUR, this, this.onUp);
      Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.onMove);
      Laya.stage.off(Laya.Event.MOUSE_UP, this, this.onUp);
      Laya.stage.off(Laya.Event.MOUSE_OUT, this, this.onUp);
      this.updateSelectState(false);
      this._touchId = -1;
      this.curDis = 0;
      this.rockerIsDown = false;
      this.rockerBar.x = this._barinitx;
      this.rockerBar.y = this._barinity;
      ((_a = this.controlTarget) == null ? void 0 : _a.onEnd) && this.controlTarget.onEnd();
    }
    /**计算鼠标位置 */
    computerRoker() {
      if (this._curspx == this._prespx && this._curspy == this._prespy)
        return;
      this._prespx = this._curspx;
      this._prespy = this._curspy;
      switch (this.rockerType) {
        case "free" /* free */:
          this.freeRockerUpdate();
          break;
        case "verticle" /* vertical */:
          this.verticleRockerUpdate();
          break;
        case "horizontal" /* horizontal */:
          this.horizontalRockerUpdate();
          break;
        default:
          break;
      }
    }
    /**计算自由鼠标位置 */
    freeRockerUpdate() {
      let value = (this._downspx - this._curspx) * (this._downspx - this._curspx) + (this._downspy - this._curspy) * (this._downspy - this._curspy);
      let dis = Math.abs(Math.sqrt(value));
      let delatx = this._curspx - this._downspx;
      let delaty = this._curspy - this._downspy;
      let angle = Math.atan2(delaty, delatx) * 180 / Math.PI;
      this.curAngle = angle;
      if (dis < this.dropdis) {
        this.rockerBar.x = this._barinitx + delatx;
        this.rockerBar.y = this._barinity + delaty;
        let pdis = Math.abs(Math.sqrt((this._barinitx - this.rockerBar.x) * (this._barinitx - this.rockerBar.x) + (this._barinity - this.rockerBar.y) * (this._barinity - this.rockerBar.y)));
        this.curDis = parseFloat((pdis / this.dropdis).toFixed(2));
      } else {
        let radians = Math.PI / 180 * angle;
        let x = Math.floor(Math.cos(radians) * this.dropdis + this._barinitx);
        let y = Math.floor(Math.sin(radians) * this.dropdis + this._barinity);
        this.rockerBar.x = x;
        this.rockerBar.y = y;
        this.curDis = 1;
      }
    }
    /**计算垂直鼠标位置 */
    verticleRockerUpdate() {
      let dis = Math.abs(this._curspy - this._downspy);
      let delatx = 0;
      let delaty = this._curspy - this._downspy;
      let angle = Math.atan2(delaty, delatx) * 180 / Math.PI;
      this.curAngle = angle;
      if (dis < this.dropdis) {
        this.rockerBar.y = this._barinity + delaty;
        this.curDis = parseFloat((Math.abs(delaty) / this.dropdis).toFixed(2));
      } else {
        let radians = Math.PI / 180 * angle;
        let y = Math.floor(Math.sin(radians) * this.dropdis + this._barinity);
        this.rockerBar.y = y;
        this.curDis = 1;
      }
    }
    /**计算水平鼠标位置 */
    horizontalRockerUpdate() {
      let dis = Math.abs(this._curspx - this._downspx);
      let delatx = this._curspx - this._downspx;
      let delaty = 0;
      let angle = Math.atan2(delaty, delatx) * 180 / Math.PI;
      this.curAngle = angle;
      if (dis < this.dropdis) {
        this.rockerBar.x = this._barinitx + delatx;
        this.curDis = parseFloat((Math.abs(delatx) / this.dropdis).toFixed(2));
      } else {
        let radians = Math.PI / 180 * angle;
        let x = Math.floor(Math.cos(radians) * this.dropdis + this._barinitx);
        this.rockerBar.x = x;
        this.curDis = 1;
      }
    }
  };
  __decorateClass([
    property3({ type: Laya.Sprite, tips: "\u6447\u6746\u8303\u56F4" })
  ], RockerControl.prototype, "touchArea", 2);
  __decorateClass([
    property3({ type: Laya.UIComponent, tips: "\u6447\u6746\u80CC\u666F" })
  ], RockerControl.prototype, "rockerBg", 2);
  __decorateClass([
    property3({ type: Laya.UIComponent, tips: "\u6447\u6746" })
  ], RockerControl.prototype, "rockerBar", 2);
  __decorateClass([
    property3({ type: RockerType, tips: "\u6447\u6746\u7C7B\u578B", options: { "\u81EA\u7531\u6447\u6746": "free" /* free */, "\u5782\u76F4\u6447\u6746": "verticle" /* vertical */, "\u6C34\u5E73\u6447\u6746": "horizontal" /* horizontal */ } })
  ], RockerControl.prototype, "rockerType", 2);
  __decorateClass([
    property3({ type: RockerShow, tips: "\u6447\u6746\u663E\u793A", options: { "\u5E38\u9A7B": "stay" /* stay */, "\u6309\u4E0B\u663E\u793A": "down" /* down */, "\u9690\u85CF": "hide" /* hide */ } })
  ], RockerControl.prototype, "rockerShow", 2);
  __decorateClass([
    property3({ type: RockerPos, tips: "\u6447\u6746\u4F4D\u7F6E", options: { "\u56FA\u5B9A": "fixed" /* fixed */, "\u8DDF\u968F": "follow" /* follow */ } })
  ], RockerControl.prototype, "rockerPos", 2);
  __decorateClass([
    property3({ type: Number, tips: "\u6447\u6746\u62D6\u62FD\u8DDD\u79BB\u9650\u5236" })
  ], RockerControl.prototype, "dropdis", 2);
  __decorateClass([
    property3({ type: Boolean, tips: "\u6447\u6746\u662F\u5426\u9501\u5B9A" })
  ], RockerControl.prototype, "rockerLock", 2);
  __decorateClass([
    property3({ type: Boolean, tips: "\u6447\u6746\u80CC\u666F\u662F\u5426\u8DDF\u968F\u65CB\u8F6C" })
  ], RockerControl.prototype, "rockerbgRotate", 2);
  __decorateClass([
    property3({ type: TargetMove, tips: "\u6447\u6746\u63A7\u5236\u5BF9\u8C61" })
  ], RockerControl.prototype, "controlTarget", 2);
  RockerControl = __decorateClass([
    regClass3("XcQqHbobRPCU4BGn1b56VA"),
    classInfo3({
      menu: "TargetControl",
      caption: "RockerControl"
    })
  ], RockerControl);
})();
